package com.ruoyi;

/**
 * @Author syc
 * @Date Created in 15:19 2022/8/17
 * @Description
 */
public class TestLambdal {
    //3.静态内部类
    static class Like2 implements  ILike {
        @Override
        public void lambda(int a) {
            System.out.println("i like lambda2-->" + a );
        }
    }

    public static void main(String[] args) {
        ILike like = new Like();
        like.lambda(1);
        like = new Like2();
        like.lambda(2);
        
        // 局部内部类
        class Like3 implements  ILike {
            @Override
            public void lambda(int a) {
                System.out.println("i like lambda3-->" + a);
            }
        }
        like = new Like3();
        like.lambda(3);
        
        // 5匿名内部类,没有类的名称.博旭借助接口或者父类
        like = new ILike() {
			@Override
			public void lambda(int a) {
				 System.out.println("i like lambda4-->" + a);
			}     	
        };       
        like.lambda(4);
        // 6.用lambda
        like = (a)->{
        	System.out.println("i like lambda5-->" + a);
        };
        like.lambda(5);   
    }
//定义一个函数式接口
interface ILike {
        void lambda(int a);
}
//实现类
static class Like implements ILike {
    @Override
    public void lambda(int a) {
        System.out.println("i like lambda-->" + a);
    }
}

}
